home *** CD-ROM | disk | FTP | other *** search
- // datentryDlg.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "dtime.h"
- #include "resource.h"
- #include "dateDlg.h"
-
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- CDatentryDlg::CDatentryDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDatentryDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDatentryDlg)
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-
- m_CDate = CDate::CurrentDate();
- m_CLTimeSpan = CLTimeSpan(1, 2, 3, 4);
- m_CLTimeOfDay = CLTimeOfDay(1, 2, 3);
- m_CLDate = CLDate::CurrentTime(LOCAL);
-
- m_LDNoSeconds = FALSE;
- m_TODNoSeconds = FALSE;
- m_TSNoSeconds = FALSE;
-
- m_LDNoUCT = FALSE;
- m_LDNoET = FALSE;
- m_LDNoLocal = FALSE;
- }
-
- void CDatentryDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDatentryDlg)
- //}}AFX_DATA_MAP
-
- //connect to the controls
- DDX_CDateControl(pDX, IDC_CDATE, m_ctrlCDate, 0);
- DDX_CLTimeSpanControl(pDX, IDC_CLTIMESPAN, m_ctrlCLTimeSpan, m_TSNoSeconds ? DT_NOSECONDS : 0);
- DDX_CLTimeOfDayControl(pDX, IDC_CLTIMEOFDAY, m_ctrlCLTimeOfDay, m_TODNoSeconds ? DT_NOSECONDS : 0);
- DDX_CLDateControl(pDX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
-
-
- //retreive / set the actual values
- DDX_CDate(pDX, m_ctrlCDate, m_CDate);
- DDX_CLTimeSpan(pDX, m_ctrlCLTimeSpan, m_CLTimeSpan);
- DDX_CLTimeOfDay(pDX, m_ctrlCLTimeOfDay, m_CLTimeOfDay);
- DDX_CLDate(pDX, m_ctrlCLDate, m_CLDate);
- }
-
- BEGIN_MESSAGE_MAP(CDatentryDlg, CDialog)
- //{{AFX_MSG_MAP(CDatentryDlg)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_ABOUT, OnAbout)
- ON_BN_CLICKED(IDC_LD_NOSECONDS, OnLdNoseconds)
- ON_BN_CLICKED(IDC_TOD_NOSECONDS, OnTodNoseconds)
- ON_BN_CLICKED(IDC_TS_NOSECONDS, OnTsNoseconds)
- ON_BN_CLICKED(IDC_LD_NOET, OnLdNoet)
- ON_BN_CLICKED(IDC_LD_NOLOCAL, OnLdNolocal)
- ON_BN_CLICKED(IDC_LD_NOUCT, OnLdNouct)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CDatentryDlg message handlers
-
- BOOL CDatentryDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
-
- void CDatentryDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
-
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CDatentryDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
-
- void CDatentryDlg::OnAbout()
- {
- AboutDTime();
- }
-
- void CDatentryDlg::OnTodNoseconds()
- {
- m_TODNoSeconds = !m_TODNoSeconds;
-
- CDataExchange DX(this, TRUE);
- DDX_CLTimeOfDayControl(&DX, IDC_CLTIMEOFDAY, m_ctrlCLTimeOfDay, m_TODNoSeconds ? DT_NOSECONDS : 0);
-
- CDataExchange DX2(this, FALSE);
- DDX_CLTimeOfDay(&DX2, m_ctrlCLTimeOfDay, m_CLTimeOfDay);
- }
-
- void CDatentryDlg::OnTsNoseconds()
- {
- m_TSNoSeconds = !m_TSNoSeconds;
-
- CDataExchange DX(this, TRUE);
- DDX_CLTimeSpanControl(&DX, IDC_CLTIMESPAN, m_ctrlCLTimeSpan, m_TSNoSeconds ? DT_NOSECONDS : 0);
-
- CDataExchange DX2(this, FALSE);
- DDX_CLTimeSpan(&DX2, m_ctrlCLTimeSpan, m_CLTimeSpan);
- }
-
- void CDatentryDlg::OnLdNoseconds()
- {
- m_LDNoSeconds = !m_LDNoSeconds;
-
- CDataExchange DX(this, TRUE);
- DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
-
- CDataExchange DX2(this, FALSE);
- DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
- }
-
- void CDatentryDlg::OnLdNoet()
- {
- m_LDNoET = !m_LDNoET;
-
- CDataExchange DX(this, TRUE);
- DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
-
- CDataExchange DX2(this, FALSE);
- DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
- }
-
- void CDatentryDlg::OnLdNolocal()
- {
- m_LDNoLocal = !m_LDNoLocal;
-
- CDataExchange DX(this, TRUE);
- DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
-
- CDataExchange DX2(this, FALSE);
- DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
- }
-
- void CDatentryDlg::OnLdNouct()
- {
- m_LDNoUCT = !m_LDNoUCT;
-
- CDataExchange DX(this, TRUE);
- DDX_CLDateControl(&DX, IDC_CLDATE, m_ctrlCLDate, GetLDFlags());
-
- CDataExchange DX2(this, FALSE);
- DDX_CLDate(&DX2, m_ctrlCLDate, m_CLDate);
- }
-
-
- DWORD CDatentryDlg::GetLDFlags() const
- {
- DWORD dwFlags = 0;
-
- if (m_LDNoSeconds)
- dwFlags |= DT_NOSECONDS;
- if (m_LDNoLocal)
- dwFlags |= DT_NOLOCAL_TIMEFRAME;
- if (m_LDNoET)
- dwFlags |= DT_NOET_TIMEFRAME;
- if (m_LDNoUCT)
- dwFlags |= DT_NOUCT_TIMEFRAME;
-
- return dwFlags;
- }